﻿using HospitalSelfServiceMachine.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HospitalSelfServiceMachine.Views
{
    /// <summary>
    /// RegisterView.xaml 的交互逻辑
    /// </summary>
    public partial class RegisterView : UserControl
    {
        public RegisterView()
        {
            InitializeComponent();
            this.DataContext = new RegisterViewModel();
        }

        public T FindVisualChild<T>(DependencyObject obj) where T : DependencyObject
        {
            if (obj != null)
            {
                for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
                {
                    DependencyObject child = VisualTreeHelper.GetChild(obj, i);
                    if (child != null && child is T)
                    {
                        return (T)child;
                    }
                    T childItem = FindVisualChild<T>(child);
                    if (childItem != null) return childItem;
                }
            }
            return null;
        }
        private void btn_nav_right_Click(object sender, RoutedEventArgs e)
        {
            ScrollViewer scroll = FindVisualChild<ScrollViewer>(nav_datetime);
            if(scroll != null)
            {
                scroll.LineRight();
            }
           
        }

        private void btn_nav_left_Click(object sender, RoutedEventArgs e)
        {
            ScrollViewer scroll = FindVisualChild<ScrollViewer>(nav_datetime);
            if (scroll != null)
            {
                scroll.LineLeft();
            }
        }
    }
}
